(function() {
	window.forgotpassword = {
		init: function() {
			forgotpassword.telephone = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
			forgotpassword.events()
		},
		signin: function() {

		},
		events: function() {
			common.focu("input", "green")
			$(".mui-btn-primary").on("tap", function() {
				var self = this
				var phone = document.getElementsByClassName("phone")[0]
				if(!forgotpassword.telephone.test(phone.value)) {
					mui.toast("请输入正确的手机号码!")
					return
				}
				common.ajax("student/sendVerifyCode", {
					phone: phone.value,
					type: 2
				}, function(data) {
					if(data.code == 200) {
						common.countdown(self, 60, "#ababab", "#40CC8B",'重新获取')
						mui.toast("发送成功!")
					} else {
						mui.toast(data.message)
					}
				})
			})
			$(".next-button").on("tap", function() {
				var phone = document.getElementsByClassName("phone")[0]
				if(!forgotpassword.telephone.test(phone.value)) {
					mui.toast("请输入正确的手机号码!")
					return
				}
				if($("#code").val().length < 4) {
					mui.toast("验证码不能少于4位!")
					return
				}
				common.ajax("student/verifyCode", {
					type:2,
					phone: phone.value,
					code: $("#code").val()
				}, function(data) {
					if(data.code == 200) {
						localStorage.setItem("uid",data.data.uid)
						common.open("determinemodify.html", "","")
					} else {
						mui.toast(data.message)
					}
				})
			})
		}
	}
	forgotpassword.init()
})()